package com.mychart.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mychart.entity.domain.HttpRes;
import com.mychart.entity.dto.UserDTO;
import com.mychart.entity.po.ChartUserPO;
import com.mychart.service.IChartUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/auth")
public class AuthorController {

    @Autowired
    IChartUserService chartUserService;
    @PostMapping("login")
    public HttpRes login (@RequestBody UserDTO userDTO) {
        QueryWrapper<ChartUserPO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name",userDTO.getUserName());
        ChartUserPO one = chartUserService.getOne(queryWrapper);
        if(one == null) {
            return HttpRes.error();
        }else {
            return HttpRes.success();
        }
    }
}
